// 
//  Copyright (C) 2009 Jacek Trubłajewicz
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 

using System;
using System.Drawing;
using Mono.Unix;
using NLog;

namespace wxGadu
{

	public class HistoryTreePanel : wx.Panel
	{
		#region Id
		public enum Id
		{
			contactsTree = 3588
		}
		#endregion
		
		#region controls
		private wx.TreeCtrl contactsTree;
		private wx.BoxSizer topSizer;
		#endregion
		
		#region data members
		private MainFrame mainFrame;
		#endregion
		
		
		public HistoryTreePanel(wx.Window parent):
			base(parent)
		{
			wx.SplitterWindow splitter = (wx.SplitterWindow) parent;
			HistoryFrame historyFrame =  (HistoryFrame) splitter.Parent;
			mainFrame = (MainFrame) historyFrame.MainFrame;
			
			wx.ImageList icons = new wx.ImageList(16, 16);
			icons.Add(mainFrame.ImageMgr[ImageManager.HISTORY]);
			icons.Add(mainFrame.ImageMgr[ImageManager.NEW_CONTACT]);
			icons.Add(mainFrame.ImageMgr[ImageManager.HISTORY_CHAT]);
			
			contactsTree = new wx.TreeCtrl(this, (int) Id.contactsTree, 
			                               wx.Window.wxDefaultPosition, new Size(180, 350),
			                               wx.TreeCtrl.wxTR_HAS_BUTTONS|wx.Window.wxBORDER_MASK);
			contactsTree.AssignImageList(icons);
			
			DoLayout();
			
			EVT_TREE_ITEM_ACTIVATED((int) Id.contactsTree, new wx.EventListener(historyFrame.OnTreeItemAcitvated));
			EVT_TREE_ITEM_EXPANDING((int) Id.contactsTree, new wx.EventListener(historyFrame.OnTreeItemExpanded));
		}
		
		private void DoLayout()
		{
			topSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
			{
				topSizer.Add(contactsTree, 1, wx.Stretch.wxEXPAND);
			}
			
			topSizer.Fit(this);
			topSizer.SetSizeHints(this);
			this.Sizer = topSizer;
		}
		
		public wx.TreeCtrl ContactsTree
		{
			get { return contactsTree; }
		}
	}
}
